import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import 'logic.dart';
import 'state.dart';

class MainPage extends StatelessWidget {
  MainPage({Key? key}) : super(key: key);

  final MainLogic logic = Get.put(MainLogic());
  final MainState state = Get.find<MainLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("公司详情查询"),
      ),
      body: ListView(
        children: [
          Padding(
            padding: const EdgeInsets.fromLTRB(15, 15, 15, 0),
            child: TextField(
              maxLength: 6,
              inputFormatters: [FilteringTextInputFormatter.digitsOnly],
              keyboardType: const TextInputType.numberWithOptions(decimal: true),
              decoration: const InputDecoration(
                border: OutlineInputBorder(),
                hintText: '请输入股票代码',
              ),
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(15),
            child: MaterialButton(
              onPressed: () {
                logic.queryBasicInfo("002351");
              },
              color: const Color(0xFFFC5233),
              elevation: 0,
              highlightColor: Colors.transparent,
              colorBrightness: Brightness.dark,
              highlightElevation: 0,
              splashColor: Colors.transparent,
              disabledColor: const Color(0x80FC5233),
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
              height: 45,
              child: const Text(
                "查询",
                style: TextStyle(fontSize: 16, color: Colors.white),
              ),
            ),
          )
        ],
      ),
    );
  }
}
